package com.iotp.service.crop;

import com.iotp.dao.crop.CropMapper;
import com.iotp.entity.crop.Crop;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("cropService")
public class CropServiceImpl implements CropService {
    @Autowired
    private CropMapper cropMapper;

    @Override
    public Long add(Crop crop) {
        this.cropMapper.insert(crop);
        return crop.getId();
    }

    @Override
    public void edit(Crop crop) {
        this.cropMapper.updateByPrimaryKeySelective(crop);
    }

    @Override
    public void del(Long id) {
        this.cropMapper.deleteByPrimaryKey(id);
    }

    @Override
    public List<Crop> queryList(Crop crop) {
        return this.cropMapper.selectByCondition(crop);
    }

    @Override
    public Crop queryById(Long id) {
        return this.cropMapper.selectByPrimaryKey(id);
    }
}
